﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DingApi.Models;
using System.Data;
 

using System.Web;
using Dingding.Helper;

using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace DingApi.Controllers
{

     //[RoutePrefix("api/Pasi15_inq")]
    public class Pasi15_inqController : ApiController
    {

       [HttpGet]
        public System.Data.DataSet GetAllPasi15_inq(string user_id)
        {
            EI.EIInfo inBlock = new EI.EIInfo();

            inBlock.sys_info.company_code = "LT";
            inBlock.sys_info.userid = user_id;//需要从前台获取

           //公司代码
            EI.EIInfo outBlock = EI.EITuxedo.CallService("pabm05_inq2", inBlock);

            outBlock.Tables[0].Columns[0].ColumnName = "CODE";
            outBlock.Tables[0].Columns[1].ColumnName = "CODE_DESC_1_CONTENT";

           
           
            //outBlock.Tables[0].Rows.Add();//表尾插入；

            //指定行i 后插入，且必须赋值，小程序不接受空值，否则会当做null处理 ；
            DataRow dr      = outBlock.Tables[0].NewRow();
            //dr.ItemArray    = outBlock.Tables[0].Rows[0].ItemArray;
            //dr["code"]    = "";
            dr["CODE"] = " ";
            dr["CODE_DESC_1_CONTENT"] = " ";
            outBlock.Tables[0].Rows.InsertAt(dr, 0);
           

           //仓库权限；
            string sql_str1 = " select t.STOCK_NO CODE ,t.stock_name as CODE_DESC_1_CONTENT  ,t.COMPANY_CODE     from tsimm01 t,tsimm04 tt ";

           sql_str1 +=" WHERE t.stock_no = tt.stock_no and tt.staff_id = '"+user_id+"' " ;
           sql_str1 += " and t.stock_type in ('6','7','8','9') order by t.stock_name asc ";

            //仓库代码转换
           EI.EIInfo outBlock2 = EF.Utility.ExecQuery(sql_str1);

           outBlock.Tables[0].TableName = "T_COMPANY_CODE";
           outBlock2.Tables[0].TableName = "T_STOCK_NO";
           outBlock.Tables.Add(outBlock2.Tables[0].Copy());

            return outBlock;
        }

 


 


      
 

       
    }
}